package com.windfone.dao.impl.jdbc.mysql;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowCallbackHandler;

import com.windfone.dao.InvoiceDao;
import com.windfone.model.Invoice;

public class InvoiceDaoImpl implements InvoiceDao {
	private JdbcTemplate jdbcTemplate;
	public void setJdbcTemplate(JdbcTemplate jdbcTemplate) { 
		this.jdbcTemplate = jdbcTemplate;
	}
	public int deleteInvoice(int keyValue) {
		return 0;
	}

	String GET_ALL_NUMBER_SQL = " SELECT COUNT(1) FROM  invoice  ";
	public int getAllRecorderNumber() {
		final List<Integer> result = new ArrayList<Integer>();
		try {
			jdbcTemplate.query(
					GET_ALL_NUMBER_SQL,
					new RowCallbackHandler() {
						public void processRow(ResultSet rs) throws SQLException {
							result.add( rs.getInt(1));
						}
					}
			);
		} catch (Exception e) {
			e.printStackTrace();
		}
		if (result.size()>0 )
			return (result.get(0)).intValue();
		else 
			return 0;
	}

	public int updateInvoice(Invoice bean) {
		return 0;
	}

	public int insertFitting(Invoice bean) {
		return 0;
	}

	public List<Invoice> getInvoiceById(int keyValue) {
		return null;
	}

	public List<Invoice> getAllInvoice(int beginRecord) {
		return null;
	}

}
